package com.example.lib_log.logger

import android.util.Log
import com.example.lib_log.ILogger
import com.example.lib_log.LoggerLevel
import java.util.logging.Level

class LogcatLogger:ILogger {
    private var isDebug = true
    private var TAG = ""
    private var level = LoggerLevel.Debug
    private var loggerFormat = "(:=>$TAG %s -->%s"
    private var url = ""
    override fun d(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.Debug.ordinal){
            Log.d(TAG,String.format(loggerFormat,tag,log))
        }
    }

    override fun v(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.Verbose.ordinal){
            Log.v(TAG,String.format(loggerFormat,tag,log))
        }
    }

    override fun i(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.Info.ordinal){
            Log.i(TAG,String.format(loggerFormat,tag,log))
        }
    }

    override fun w(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.Warn.ordinal){
            Log.w(TAG,String.format(loggerFormat,tag,log))
        }
    }

    override fun e(tag: String, log: String) {
        if(isDebug && level.ordinal >= LoggerLevel.Error.ordinal){
            Log.e(TAG,String.format(loggerFormat,tag,log))
        }
    }

    override fun log(level: Level, msg: String) {

    }

    override fun log(level: Level, msg: String, th: Throwable) {

    }

    override fun setDebug(isDebug: Boolean) {
        this.isDebug = isDebug
    }

    override fun setLogTAG(TAG: String) {
        this.TAG = TAG
    }

    override fun setLogLevel(level: LoggerLevel) {
        this.level = level
    }

    override fun setSaveUrl(url: String) {
        this.url = url
    }
}